import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'

import './assets/css/reset.css'
import './assets/css/fonts/iconfont.css'
import TreeTable from 'vue-table-with-tree-grid'

//添加富文本编辑器
import quillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(quillEditor)

//导入进度条
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'

import axios from 'axios'
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/"
//请求拦截器
axios.interceptors.request.use(config =>{
  //为请求对象添加Token认证的Authorization 字段
  Nprogress.start();
  config.headers.Authorization = window.sessionStorage.getItem('token')
   return config 
})

//响应拦截器
axios.interceptors.response.use(config =>{
   Nprogress.done();
   return config 
})
Vue.prototype.$http = axios
Vue.config.productionTip = false
Vue.component('tree-table',TreeTable)
//格式化日期全局过滤器
Vue.filter('formatDate',function(value){
  var date = new Date(value);
  var o = {
    "M+": date.getMonth() + 1, // 月份
    "d+": date.getDate(), // 日
    "h+": date.getHours(), // 小时
    "m+": date.getMinutes(), // 分
    "s+": date.getSeconds(), // 秒
    "q+": Math.floor((date.getMonth() + 3) / 3), // 季度
    "S": date.getMilliseconds() // 毫秒
    };
   var fmt = "yyyy-MM-dd hh:mm:ss";
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));

   return fmt
})



new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
